﻿/**
 * Peter
 * Created by: Peter Development Team
 *    http://peter.codeplex.com/
 * 
 * GNU General Public License version 2 (GPLv2)
 *    http://peter.codeplex.com/license
 *
 *  This code is provided on an AS IS basis, with no WARRANTIES,
 *  CONDITIONS or GUARANTEES of any kind.
 *  
 **/

using Peter.Common.Controls;
using Peter.Common.Dialog;
using Peter.Common.Interfaces;

namespace Peter.Logic
{
   /// <summary>
   /// Model for base project actions.
   /// </summary>
   public class ModelProjectBase : DialogBase
   {
      private ExplorerItem m_SelectedLocation;
      private IPeterProjectType m_SelectedItem;

      /// <summary>
      /// Initializes a new project base.
      /// </summary>
      /// <param name="projectManager">The project manager.</param>
      protected ModelProjectBase (ModelProjectManager projectManager)
      {
         this.ProjectManager = projectManager;
      }

      /// <summary>
      /// Gets the project manager.
      /// </summary>
      public ModelProjectManager ProjectManager { get; private set; }

      /// <summary>
      /// Gets or Sets the selected item in the tree.
      /// </summary>
      public IPeterProjectType SelectedItem
      {
         get { return m_SelectedItem; }
         set
         {
            this.m_SelectedItem = value;
            this.OnPropertyChanged ("SelectedItem");
         }
      }

      /// <summary>
      /// Gets or Sets the selected location.
      /// </summary>
      public ExplorerItem SelectedLocation
      {
         get { return m_SelectedLocation; }
         set
         {
            this.m_SelectedLocation = value;
            this.OnPropertyChanged ("SelectedLocation");
            this.SelectedLocationChanged (this.m_SelectedLocation.File.FullName);
         }
      }

      /// <summary>
      /// Occurs when the selected location changes.
      /// </summary>
      /// <param name="location">The new location.</param>
      protected virtual void SelectedLocationChanged (string location) { }
   }
}
